<?php
namespace App\Controller;
//namespace App\Service\ProfileService;
use App\Service\UploadService;
use App\Service\UserService;
use Swoole;
use App\Service\LoginService;
use App\DAO;
class auth extends Swoole\Controller
{
    function login()
    {

        $plat = $_GET['plat'];

        $code = $_GET['code'];
        $openid = $_GET['openid'];
        $accesstoken = $_GET['accesstoken'];

        $userService = new UserService();
        $userService->setPlat($plat);
        if($plat == 1  ) {
            $ret = $userService->loginwithcode($code);
        }
        else if($plat == 0 || $plat == 2) {
            $ret = $userService->loginWithAccessToken($openid, $accesstoken);
        }
        else
        {

        }
        return json_encode($ret);
        //$ret = $profileservice->getUserPorfile($account_list,$tag_list);
        //var_dump($ret);
    }
    function  upload()
    {
       $upload = new  UploadService();
       $ret =  $upload->upload();
    }
    function test()
    {
        $userDao = new DAO\UserDAO();
        var_dump($userDao->getone());
    }

}